package com.anos.smsfun.adapter;

import java.util.ArrayList;
import java.util.HashMap;

import android.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class IconListAdapter extends BaseAdapter {

	private Context mContext;
	private ArrayList<Integer> mArrayIcons;
	private int mWidth;
	private int mHeight;

	public IconListAdapter(Context context,  ArrayList<Integer> data) {
		mContext = context;
        mArrayIcons = data;
		mWidth = 50;
		mHeight = 50;
	}

	@Override
	public int getCount() {
		return mArrayIcons.size();
	}

	@Override
	public Object getItem(int arg0) {
		return mArrayIcons.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;
		if (convertView == null) {
			imageView = new ImageView(mContext);
			imageView.setLayoutParams(new AbsListView.LayoutParams(mWidth,
					mHeight));
		} else {
			imageView = (ImageView) convertView;
		}
        int idRes = mArrayIcons.get(position);
		imageView.setImageBitmap(BitmapFactory.decodeResource(mContext.getResources(), idRes));

		return imageView;
	}

}
